package com.dc.web.controller;

import com.dc.constant.Constants;
import com.dc.entity.CalibrationMachinePipeEntity;
import com.dc.model.AjaxResult;
import com.dc.model.PageListBody;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Api(tags = "3-机电管子焊接-0-法兰管子")
@RestController
@RequestMapping("/api/calibration_machine_pipe_falan")
@Slf4j
public class CalibrationMachinePipeFalanController {

    @Resource
    CalibrationMachinePipeController controller;

    String type = Constants.TYPE_MACHINE_PIPE_FALAN;

    @GetMapping("/list")
    public AjaxResult list(PageListBody body) {
        controller.type = type;
        return controller.list(body);
    }

    @RequestMapping("/{id}")
    public AjaxResult show(@PathVariable("id") Long id) {

        return controller.show(id);
    }

    @PostMapping()
    public AjaxResult add(@RequestBody CalibrationMachinePipeEntity entity) {
        entity.setType(type);
        return controller.add(entity);
    }

    @PutMapping("/{id}")
    public AjaxResult update(@PathVariable("id") Long id, @RequestBody CalibrationMachinePipeEntity entity) {
        entity.setType(type);
       return controller.update(id, entity);
    }

    @DeleteMapping("/{id}")
    public AjaxResult delete(@PathVariable("id") Long id) {

        return controller.delete(id);
    }
}
